import dayjs from 'dayjs'

export const now = (format) => {
  if (!format) {
    format = 'YYYY-MM-DD HH:mm:ss'
  }
  return dayjs().format(format)
}


export const toJsDate = (date) => {
  return dayjs(date).toDate();
}

export const subtractDateStr = (date, days, format) => {
  if (!format) {
    format = 'YYYY-MM-DD HH:mm:ss'
  }
  return dayjs(date).subtract(days, 'days').format(format)
}

export const subtractHourStr = (date, hour, format) => {
  if (!format) {
    format = 'YYYY-MM-DD HH:mm:ss'
  }
  return dayjs(date).subtract(hour, 'hours').format(format)
}

export const addDateStr = (date, days, format) => {
  if (!format) {
    format = 'YYYY-MM-DD HH:mm:ss'
  }
  return dayjs(date).add(days, 'days').format(format)
}
